package ua.kratik.seabattle.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import ua.kratik.seabattle.dao.api.UserDAO;
import ua.kratik.seabattle.domain.User;
import ua.kratik.seabattle.service.GenericDataService;
import ua.kratik.seabattle.service.api.UserService;

@Service
public class UserServiceImpl extends GenericDataService<User>
							implements UserService {
	
	private UserDAO userDAO;
	
	@Autowired
	public UserServiceImpl(UserDAO dao){
		super(dao);
		this.userDAO = dao;
	}

	public User validateUser(String email, String pass) {
		return userDAO.validateUser(email, pass);
	}

	public boolean isEmailFree(String email) {
		return (userDAO.findUserByEmail(email).size() == 0);
	}
	
}
